﻿@model PortalCurriculo.MvcWebUI.Models.DeficienciaProfissionalModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#editFormPNE").dialog({ autoOpen: false, modal: true, resizable: false });

        $("#IdDeficiencia").change(function () {
            $("#erroPNE").hide();
            $.post("/DeficienciaProfissional/ListarCaracteristicas", { idDeficiencia: $("#IdDeficiencia").val() }, IdDeficiencia_Callback, "Json");
        });
    });

    function IdDeficiencia_Callback(partial) {
        var dropDownCaracteristica = $('#IdCaracteristicaDeficiencia');
        dropDownCaracteristica.empty();

        var caracs = JSON.parse(partial.caracteristicas);

        $.each(caracs, function (val, item) {
            dropDownCaracteristica.append(new Option(item.Descricao, item.Id));
        });

        dropDownCaracteristica[0].selectedIndex = 0;
    }

    function onSuccessDeficienciaProfissional() {
        $("#editFormPNE").dialog('close');
    };

    function onErrorDeficienciaProfissional() {
        $("#erroPNE").show();
    };
</script>
@using (Ajax.BeginForm("Manter", new AjaxOptions { UpdateTargetId = "listaDeficienciaProfissional", OnSuccess = "onSuccessDeficienciaProfissional", OnFailure = "onErrorDeficienciaProfissional" }))
{
    <span class="displayNone error" id="erroPNE">@PortalCurriculo.MvcWebUI.Resources.Deficiencia.Geral.CaracteristicaDuplicada</span>
    <fieldset>
        <legend>@PortalCurriculo.MvcWebUI.Resources.Deficiencia.Geral.NecessidadesEspeciais</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.CaracteristicaDeficiencia.IdDeficiencia)
        </div>
        <div class="editor-field fullWidth">
            @Html.DropDownList("IdDeficiencia", (SelectList)ViewBag.IdDeficiencia, new { style = "width: 200px" })
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.IdCaracteristicaDeficiencia)
        </div>
        <div class="editor-field fullWidth">
            @Html.DropDownListFor(model => model.IdCaracteristicaDeficiencia, (SelectList)ViewBag.CaracteristicasDeficiencias, new { style = "width: 200px" })
            @Html.ValidationMessageFor(model => model.IdCaracteristicaDeficiencia)
        </div>
        @if (Model != null)
        {
            @Html.HiddenFor(model => model.Id)
            @Html.HiddenFor(model => model.IdProfissional)
        }
        <p>
            <input type="submit" value="@PortalCurriculo.MvcWebUI.Resources.Geral.Botoes.Salvar" class="buttonSave ui-button ui-widget ui-state-default ui-corner-all"  />
            <input type="button" onclick="$('#editFormPNE').dialog('close');" value="@PortalCurriculo.MvcWebUI.Resources.Geral.Botoes.Cancelar" class="buttonCancelar ui-button ui-widget ui-state-default ui-corner-all" />
        </p>
    </fieldset>
}
